import time
from socket import *

#datHex='0303300046ffff0216581770008085af7b6d046405046003c1780c2c0d30f8d77ce003beb00030aa000040c35a3330bfe000608018533be014e950064b077cbd9402ee853b4022f5'
# s-allcall
# datHex='0103300046ffff0216581770008085af7b6d046405046003c1780c2c0d30f8d77ce003beb00030aa000040c35a3330bfe000608018533be014e950064b077cbd9402ee853b4022f5'
# s-rollcall
datHex='0103300046ffff021658177000a085af7b6d046405046003c1780c2c0d30f8d77ce003beb00030aa000040c35a3330bfe000608018533be014e950064b077cbd9402ee853b4022f5'
# s-allcall+psr
# datHex='0103300046ffff021658177000c085af7b6d046405046003c1780c2c0d30f8d77ce003beb00030aa000040c35a3330bfe000608018533be014e950064b077cbd9402ee853b4022f5'
# s-rollcall+psr
# datHex='0103300046ffff021658177000e085af7b6d046405046003c1780c2c0d30f8d77ce003beb00030aa000040c35a3330bfe000608018533be014e950064b077cbd9402ee853b4022f5'
# s-rollcall+psr  高度无效
# datHex='0103300046ffff021658177000e000000000046400276003c1780c2c0d30f8d77ce003beb00030aa000040c35a3330bfe000608018533be014e950064b077cbd9402ee853b4022f5'
# datHex = '0103300043ff7f0216581770008085af7b6d046405046003c10d30f8d77ce003beb00030aa000040c35a3330bfe000608018533be014e950064b077cbd9402ee853b4022f5'

# 格式错误
# datHex='140047fdcf02168700000000005555550124fa4f000000000000006406db0076ffec000457805054d4c30c400e5a03000000000000004000000000000000500000000000000060'
# datHex = '150034c71d2b49800c00290016661d4a9c3c0b330e8e254e1e0b000bb9065a1f0008076bf4060101060002e12038353530c30c40'
HOST = '233.1.21.1'
PORT = 56023
ADDR = (HOST, PORT)
udpClient = socket(AF_INET, SOCK_DGRAM)

arry = bytearray()


def mySplit(str):
    for i in range(int(len(str) / 2)):
        arry.append(int(str[2 * i:2 * (i + 1)], 16))


mySplit(datHex)
# print(arry)
while (True):
    print(datHex.strip())
    print(arry)
    udpClient.sendto(arry, ADDR)
    time.sleep(4)

udpClient.close()
